<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>dropRightWhile</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const dropRightWhile = (arr, handler) => {
            let rightIndex = arr.length;
            while (rightIndex-- && !handler(arr[rightIndex]));
            return arr.slice(0, rightIndex);
        };
        console.log(dropRightWhile([1, 2, 3, 4], n => n < 3));
    </script>
</body>

</html>